package com.bjpowernode.dataservice.mapper;

import com.bjpowernode.api.model.FinanceAccount;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;

public interface FinanceAccountMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(FinanceAccount record);

    int insertSelective(FinanceAccount record);

    FinanceAccount selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(FinanceAccount record);

    int updateByPrimaryKey(FinanceAccount record);

    /**
     * 根据用户id查找账户 添加了行锁(uid添加了唯一索引index)
     * @param uid 用户id
     * @return
     */
    FinanceAccount selectByUidForUpdate(Integer uid);

    /**
     * 修改用户账户余额
     * @param uid 用户id
     * @param money 用户投资金额
     * @return 是否修改成功
     */
    int updateMoney(@Param("uid") Integer uid, @Param("money") BigDecimal money);

    /**
     * 修改用户账户余额(支付)
     * @param uid 用户id
     * @param incomeMoney 添加的金额
     * @param bidMoney 投资的金额
     * @return 是否修改成功
     */
    int updateMoneyByUid(Integer uid, @Param("incomeMoney") BigDecimal incomeMoney, @Param("bidMoney") BigDecimal bidMoney);

    /**
     * 给账户充值
     * @param uid 用户id
     * @param rechargeMoney 充值金额
     * @return 是否充值成功
     */
    int updateMoneyAdd(@Param("uid") Integer uid, @Param("rechargeMoney") BigDecimal rechargeMoney);
}